package com.example.controller;

import com.example.pojo.Article;
import com.example.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class HomeController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/home")
    public String home(@RequestParam(value = "page", defaultValue = "0") Integer currentPage, Model model){
        Page<Article> page = articleService.getPage(currentPage);
        model.addAttribute("page",page);
        return "/client/index";
    }

}
